package com.hjh.seata.good.controller;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.math.RandomUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/good")
public class GoodController {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @GetMapping("/amount/reduce")
    public String reduceAmount() {
        jdbcTemplate.update("INSERT INTO `seata_good`.`t_good` (`amount`) VALUES ("+ RandomUtils.nextInt() +");");
        log.info("=================================>>>good");
        return "success";
    }
}